# app/routes/hardware.py
from flask import Blueprint, jsonify
import platform
from importlib import import_module

hardware_bp = Blueprint('hardware', __name__)

def get_os_specific_hardware_info():
    os_name = platform.system().lower()
    try:
        module_name = f'app.routes.hardware-{os_name}'
        module = import_module(module_name)
        return module.get_hardware_info()
    except ImportError:
        raise Exception("Unsupported OS")

@hardware_bp.route('/hardware_info', methods=['GET'])
def hardware_info():
    try:
        result = get_os_specific_hardware_info()
        return jsonify(result), 200
    except Exception as e:
        return jsonify({'error': str(e)}), 500